//
//  RingtonePlayer.h
//  E-Plus
//
//  Created by zhenwei guan on 12-10-12.
//  Copyright (c) 2012. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>

#define kRingtoneIndexNum 3

typedef enum
{
    ShuffleMode = 1,  // 随机播放
    OrderMode,        // 顺序播放
    RepeatMode        // 单曲循环
}LoopMode;


@interface RingtonePlayer : NSObject<AVAudioPlayerDelegate>
{
    AVAudioPlayer * myPlayer;
    BOOL isLoop;
    LoopMode loopMode;
    NSUInteger currentIndex;  // from 0 to kRingtoneIndexNum-1
}

- (id)initWithIndex:(NSInteger)index andLoopMode:(BOOL)isLoop;
- (void)startPlay;
- (void)stopPlay;       
- (void)changeRingtoneToIndex:(NSInteger)index;
- (void)changeRingtoneToName:(NSString *)name;
+ (void)invokeSpeaker:(BOOL)open;

@property (nonatomic, retain) AVAudioPlayer * myPlayer;
@property (nonatomic, assign) BOOL isLoop;
@property (nonatomic, assign) LoopMode loopMode;
@property (nonatomic, assign) NSUInteger currentIndex;

@end
